package top.revery.datasource.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.revery.datasource.dto.CategoryDto;
import top.revery.datasource.dto.ChinaCityDto;
import top.revery.datasource.dto.HotKeyWordDto;
import top.revery.datasource.dto.WebPagesDto;

import javax.annotation.PostConstruct;

/**
 * <h1> --- 数据库访问映射 --- </h1>
 * Created by  revery.top jun
 * Date  2019-12-05 11:48
 */
@Component
public class dsource {

    /*
    * 分类表
    * */
    public static CategoryDto categoryDto;

    /*
    * 省市区
    * */
    public static ChinaCityDto chinaCityDto;


    /*
     * 单页面
     * */
    public static WebPagesDto webPagesDto;

    /*
     * 热门搜索
     * */
    public static HotKeyWordDto hotKeyWordDto;

    @Component
    public class AutoLoadData{
        @Autowired
        private CategoryDto categoryDto;

        @Autowired
        private ChinaCityDto chinaCityDto;

        /*
         * 单页面
         * */
        @Autowired
        private WebPagesDto webPagesDto;

        /*
         * 热门搜索
         * */
        @Autowired
        private HotKeyWordDto hotKeyWordDto;

        @PostConstruct
        void init(){
            dsource.categoryDto = this.categoryDto;
            dsource.chinaCityDto = this.chinaCityDto;
            dsource.webPagesDto = this.webPagesDto;
            dsource.hotKeyWordDto = this.hotKeyWordDto;
        }
    }
}
